本文說明如何為 eap-mcp
模組準備 Gradle 依賴與常見設定,讓 MCP 工具可以順利編譯、注入以及與其他服務(如 wallet/order)整合。
在 eap-mcp/build.gradle
包含下列重點:
下面是 eap-mcp/build.gradle
的完整內容,我會在之後針對關鍵相依做逐段說明:
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.3'
id 'io.spring.dependency-management' version '1.1.7'
}
group = 'com.eap'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '17'
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
}
dependencies {
// EAP Common DTOs
implementation project(':eap-common')
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
// 使用spring-ai 提供的 MCP Server WebMVC Starter
implementation 'org.springframework.ai:spring-ai-starter-mcp-server-webmvc:1.1.0-M1'
// HTTP Client for calling order-service
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
// Logging and metrics
implementation 'io.micrometer:micrometer-registry-prometheus'
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// Testing
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
org.springframework.boot:spring-boot-starter-web
org.springframework.boot:spring-boot-starter-validation
javax.validation
/Jakarta Bean Validation(例如 @Valid
、@NotNull
),方便在工具的方法參數上做入參驗證,避免錯誤的輸入造成系統異常。org.springframework.boot:spring-boot-starter-actuator
/actuator/health
)、metrics、和運維端點,好在部署與監控上整合 Prometheus / Grafana。org.springframework.ai:spring-ai-starter-mcp-server-webmvc:1.1.0-M1
org.springframework.cloud:spring-cloud-starter-openfeign
WalletServiceClient
、OrderServiceClient
)。io.micrometer:micrometer-registry-prometheus
lombok
(compileOnly + annotationProcessor)